#ifndef _CMDLINE_H
#define _CMDLINE_H

/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+                                                                   +
+ cmdline.c - processes the command-line                            +
+                                                                   +
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/

/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ declarations                                                      +
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/

//#define DBG_CMDLINE		1

#ifdef DBG_CMDLINE
#define DBG_CMDLINE0(str)				printf("handleArguments(): "); printf(str);
#define DBG_CMDLINE1(str,arg1)			printf("handleArguments(): "); printf(str,arg1);
#define DBG_CMDLINE2(str,arg1,arg2)		printf("handleArguments(): "); printf(str,arg1,arg2);
#else
#define DBG_CMDLINE0(str)
#define DBG_CMDLINE1(str,arg1)
#define DBG_CMDLINE2(str,arg1,arg2) 
#endif	

#define DEF_HEAP		64		/* default heap = 64KB = 65,536 bytes */
#define DEF_STACK		64		/* default stack = 64KB = 65,536 bytes */

struct CmdLine
{
	char *binaryFile;		/* name of the bytecode file to execute */
//	U8 heapRequest;			/* RAM to allocate for heap in KB*/
//	U8 stackRequest;		/* RAM to allocate for stack in KB*/
	U1 debug;				/* if TRUE, start in debug mode */
	U1 ok;					/*TRUE or FALSE*/
};

#define MAX_PROGRAM_ARGS	32
struct ProgramArgs
{
	char *args[MAX_PROGRAM_ARGS];	/* program arguments */
	U1 nArgs;						/* number of arguments */
};
struct ProgramArgs programArgs;

struct ApplicationMetaData
{
	char *fileName;		/*cmdline.c in bytes*/
	U8 fileSize;		/*init.c*/
	U8 bCodeFileStart;	/*init.c*//* file information */
	U8 bCodeFileEnd;	/*init.c*//*----------------------*/
	U8 ram;				/*init.c*//* memory information */
	U8 bSizeLoadedModule;		//the size of loaded module 
};

struct ApplicationMetaData appMetaData;	/*global used by debugger*/

/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ private prototypes                                                +
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/

void printUsage();

void badHeapSize(char *str);
void badHeapOption();

void badStackSize(char *str);
void badStackOption();

void badOptionChar(char ch);

/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ public prototypes                                                 +
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/

struct CmdLine handleArguments(int argc, char *argv[]);

#endif
